#include "widget.h"
#include "ui_widget.h"


Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    tcr = new teacher(this);
    sdt = new student(this);

    //关联信号的槽
    connect(tcr, &teacher::MySignal, sdt, &student::StartStudy);
    QPushButton* PB = new QPushButton(this);
    PB->setText("上课了");
    PB->move(200, 200);
    PB->resize(300, 300);
    //关联按钮和信号
    connect(PB, &QPushButton::clicked, tcr, &teacher::MySignal);
    //发射信号
    EmitSignal();
}

Widget::~Widget()
{
    delete ui;
}

void Widget::EmitSignal()
{
    emit tcr->MySignal();
}

